home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 322 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  4.1 KB

  1. Path: hecate.umd.edu!ram
  2. From: ram@mbisgi.umd.edu (Ram Samudrala)
  3. Newsgroups: comp.infosystems.www.misc,comp.lang.misc,comp.lang.perl.misc,comp.lang.c
  4. Subject: Perl vs. C (was Re: Unix or NT? Get a Mac!)
  5. Followup-To: comp.infosystems.www.misc,comp.lang.misc,comp.lang.perl.misc,comp.lang.c
  6. Date: 4 Jan 1996 12:04:57 GMT
  7. Organization: The Centre for Advanced Research in Biotechnology
  8. Message-ID: <4cgfp9$pje@hecate.umd.edu>
  9. Reply-To: me@ram.org
  10. NNTP-Posting-Host: iris3.carb.nist.gov
  11. X-Newsreader: TIN [version 1.2 PL0]
  12.  
  13. Cross-posted to comp.lang.c; previous thread in its entirety is in
  14. comp.infosystems.www.misc.
  15.  
  16. Mike Heins (mheins@bluestem.prairienet.org) wrote:
  17.  
  18. >If you are an ACM contest programmer, that is fine.  For the rest of
  19. >us, time spent programming is roughly proportional to lines of code.
  20.  
  21. Is it really?  My iterative solution took me a shorter time to program
  22. (than the recursive one) even though it has the same # of lines (it
  23. runs faser too) and as I said the Perl version is about the same
  24. length.  In fact, what I did was write one loop, copy it 9 times, and
  25. simply went in and changed the variables.  With the recursive version
  26. also I was able to copy lines in at least 2-3 cases.
  27.  
  28. >And if I remove the same from Tom's, it comes to 20 lines.
  29.  
  30. All right, I rewrote the program slightly (I don't program like this,
  31. but I know many people who do) so not be symmetrical, to not use
  32. multiple lines for declarations (I had 4 lines with "int ..", whereas
  33. I could just had one line "int x, y, z"), not use multiple lines for
  34. initialisation (C hack: foo = bar = baz = 2, whic I hate).  I get 29
  35. lines.  If used array initalisation when declaring, it'd be about 2
  36. lines shorter.  I did the same for Tom (put the '{'s on a separate
  37. line), then I issue the command:
  38.  
  39. sort program | uniq | grep -v '{' | grep -v '}' | wc
  40.  
  41. For Tom, I get 18 lines, and for my program I get 29.  Now, this about
  42. 1.5 times more than Tom's (hardly the factor of 10 someone claimed).
  43. I'm sure Tom could put the whole bloody thing in one line... as could
  44. I.  I think this is well within some standard fluctuation.  (And I
  45. will remind you about the iterative solution again.)
  46.  
  47. >I wasn't privy to that code when I made my post.
  48.  
  49. No, but I said it was highly similar---did you not believe me?
  50.  
  51. >All this is fine if you can type as fast as you think.  Most people are 
  52. >not ACM contest programmers.  
  53.  
  54. Well, if you read Paul Phillps' post (and actually everone who
  55. disagreed with me then), that's how this whole thing started.   I'm
  56. sure there're ACM problems that Perl might do better (but I can't
  57. think of one---anyone?), but the statement "Perl would make it too
  58. easy" is not at all true. Most of the problems in my experience that
  59. can be done really fast are problems like this, which are not too
  60. dependent on language, and I've used many recursive solutions in my
  61. time. 
  62.  
  63. >count this problem as text-intensive.  It is recursion-intensive.
  64.  
  65. But there's an iterative solution---in fact, it is with the recursive
  66. solution that Perl actually manages to make the program shorter.
  67.  
  68. >We already conceded the time to run -- why do you keep harping on
  69. >it? 
  70.  
  71. Because, again, if you read the original thread, some of the claims
  72. were like "the factor of time to code is 10 times more and the
  73. execution speed is only 2-3 times less".  Hardly borne out in this
  74. example, is it?  And I agreed this might be true for simple
  75. algorithms---but as I clearly stated, after the algorithm acquires a
  76. certain complexity, this is no longer true. My claims were made under
  77. highly specific situations.
  78.  
  79. >Perl does not claim to be all things to all people, and I don't think C
  80. >can claim it either.
  81.  
  82. I don't and never have disputed this.  C shell scripts at some point
  83. are better than doing it in C, but this whole discussion arose under a
  84. specific comment I made, which was about complexity and the ACM
  85. contests.
  86.  
  87. --Ram
  88.  
  89. me@ram.org  ||  http://www.ram.org  ||  http://www.twisted-helices.com/th
  90.   Tell me why I have to be a powerslave?
  91.   I don't want to die I'm a god why can't I live on?  
  92.   When the life giver dies all around is laid waste.  
  93.   And In my last hour I'm a slave to the power of death.   ---Iron Maiden
  94.